package com.study.spmongodb.wwj.thread2.char08;

/**
 * @author study
 * @version 1.0
 * @date 2020/12/8 16:01
 */
public class FutureSerivce {

    public <T> Future<T> sumbit(final FutureTask<T> task) {
        AsyncFuture<T> asyncFuture = new AsyncFuture<>();
        new Thread(() -> {
            try {
                T call = task.call();
                asyncFuture.done(call);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }).start();
        return asyncFuture;
    }
}
